package month12;

import java.util.concurrent.*;

public class ThreadPoolTest {
    private static ExecutorService threadPool =
            new ThreadPoolExecutor(2, 5, 1000, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>(),
            Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        Future<String> future01 = threadPool.submit(() -> {
            return "call01"+Thread.currentThread().getName();
        });
        Future<String> future02 = threadPool.submit(() -> {
            return "call02"+Thread.currentThread().getName();
        });
        Future<String> future03 = threadPool.submit(() -> {
            return "call03"+Thread.currentThread().getName();
        });
        Future<String> future04 = threadPool.submit(() -> {
            return "call04"+Thread.currentThread().getName();
        });
        Future<String> future05 = threadPool.submit(() -> {
            return "call05"+Thread.currentThread().getName();
        });

        System.out.println(future01.get());
        System.out.println(future02.get());
        System.out.println(future03.get());
        System.out.println(future04.get());
        System.out.println(future05.get());


/*        System.out.println(threadPool.submit(call01).get());
        System.out.println(threadPool.submit(call02).get());
        System.out.println(threadPool.submit(call03).get());
        System.out.println(threadPool.submit(call04).get());
        System.out.println(threadPool.submit(call05).get());*/


    }

}
